
var pathName = window.location.pathname.substring(1);
var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
var basePath = window.location.protocol + '//' + window.location.host + '/' + webName;

$(function(){
	$.ajax({
		type: "POST",
        url: basePath + "/hot",
        data: {},
        dataType: "html",
		success: function(data){
			data = eval("("+data+")");
			var html = "";
			for(var o in data){
				//alert(o);
				html += "<li><a href=\""+ data[o].chapUrl +"\" target=\"_blank\">"+ data[o].chapName +"</a></li>";
			}
			$("#bookNum").html("（共查询到：" + data.length + "本图书）");
			$(".hot").html(html);
		},error: function(XMLHttpRequest, textStatus){
			alert(XMLHttpRequest.status);
            alert(XMLHttpRequest.readyState);
            alert(textStatus);
			console.log("error");
		}
	});
});

$(".hotport").click(function click(){
	var value = $(this).find('input').val();
	$('#beanForm').attr('action', basePath + "/search/" + value + "/0");
	$('#beanForm').submit();
});

$(".searchBtn").click(function click(){
	var value = $('#search').val();
	$('#beanForm').attr('action', basePath + "/search/" + value + "/0");
	$('#beanForm').submit();
});

